package com.zone.component_home.viewmodel

import android.util.Log
import androidx.databinding.ObservableArrayList
import androidx.databinding.ObservableInt
import androidx.fragment.app.Fragment
import com.zone.component_home.fragment.AdventureFragment
import com.zone.component_home.fragment.ChatFragment
import com.zone.component_home.fragment.MineFragment
import com.zone.component_home.fragment.SquareFragment
import com.zone.component_home.model.TabModel
import com.zone.core.base.BaseViewModel
import com.zone.core.model.EVENT_BACK

class HomeActivityVM(str: String) : BaseViewModel() {
    val selectItem = ObservableInt(0)
    val TAG = "BaseActivityVM"
    val tabs = ObservableArrayList<TabModel>()
    val fragments = listOf<Fragment>(
        AdventureFragment(), SquareFragment(), ChatFragment(), MineFragment()
    )
    var thisTab: TabModel? = null

    init {
        tabs.add(TabModel("------------", "探索"))
        tabs.add(TabModel("------------", "广场"))
        tabs.add(TabModel("------------", "消息"))
        tabs.add(TabModel("------------", "我的"))
    }

    fun onClickTab(tab: TabModel) {
        Log.d(TAG, "onClickTab: =============" + tab.name)
        if (thisTab == tab) {
            return
        }
        thisTab = tab
        postEvent(tabs.indexOf(tab))
    }

    fun getTab(): Int {
        Log.d(TAG, "onClickTab: =============")
        return 1
    }
}